<?php
  require_once('tpl/header.php');
?>
 <?php 
          require_once("../system/loginCheck.php");
	      require_once("../system/dbConn.php");
	      connect();
    $videoname=$_POST["videoname"];
	$videotype=$_POST["videotype"];
	$intro=$_POST["intro"];
	$address=$_POST["address"];
	$uploadadmin=$_SESSION["adminid"];
	//var_dump($_SESSION);
	
//海报图片的文件上传
	 if ($_FILES["pic"]["error"]) {
      switch ($_FILES["pic"]["error"]) {
        case '1':
            echo "文件尺寸超过了配置文件的最大值";
          # code...
          break;
          case '3':
            echo "部分文件上传";
          # code...
          break;
        case '4':
            echo "没有文件上传";
          # code...
          break;
        
        default:
          # code...
          break;
      }
      # code...
    }
    $arr=explode(".",$_FILES["pic"]["name"]);
    $suffix=$arr[count($arr)-1];
    //判定文件类型是不是图片
    $allowtype=array("jpg","jpeg","png","PNG","JPG","JPEG","Bmp","gif");
    if (!in_array($suffix, $allowtype)) {
      //扩展名不在xx中
      //echo "文件上传错误";
      //exit;//脚本退出结束
      die("文件上传错误");

    }
    //拷贝,文件命名使用系统时间加三位随机数命名
    
    $filePath="../posters/";
   
    $randname=date("YmdHis").rand(100,999).".".$suffix;
   if (move_uploaded_file($_FILES["pic"]["tmp_name"], $filePath.$randname)) {
      # code...//文件拷贝
    echo "海报图片文件上传成功";
    } 
    //取管理员的adminid
   
    //sql语句
      $time=date('Y-m-d');
      // var_dump(expression)
      $sql="insert into videos values (null,'$videoname',$videotype,'$randname','$intro','$time',$uploadadmin,0,0,'$address')";

    //echo $sql;
    $result=mysql_query($sql);
   if ($result==1) {
   echo "视频添加成功，3秒后返回添加页面可以继续添加";
   header("refresh:3;url='videoAdd.php'");
   }
   else{
   	echo "视频添加失败";
   }
   

  ?>
   


<?php
  require_once('tpl/footer.php');
?>